package me.jzn.alib.custom.uri;

import android.net.Uri;

public interface BaseCustomUri {
    public static final String SCHEME_ACTIVITY = "activity";
    public static final String SCHEME_RES = "res";
    public static final String SCHEME_ASSETS = "assets";

    public String getScheme();

    public static BaseCustomUri parse(Uri uri) {
        String scheme = uri.getScheme();
        if (BaseCustomUri.SCHEME_ACTIVITY.equals(scheme)) {
            return new ActivityUri(uri);
        } else if (BaseCustomUri.SCHEME_RES.equals(scheme)) {
            return new ResUri(uri);
        } else if (BaseCustomUri.SCHEME_ASSETS.equals(scheme)) {
            return new AssetsUri(uri);
        } else if ("file".equals(scheme)) {
            String path = uri.getPath();
            if (path.startsWith("/android_res")) {
                return new ResUri(uri);
            } else if (path.startsWith("/android_asset")) {
                return new AssetsUri(uri);
            }
            return new CommUri(uri);
        }
        return new CommUri(uri);
    }
}
